/*
 * @lc app=leetcode.cn id=125 lang=javascript
 *
 * [125] 验证回文串
 */

// @lc code=start
/**
 * @param {string} s
 * @return {boolean}
 */
var isPalindrome = function (s) {
  let removeStr = filterNonNumberAndNonChar(s)

  const str = removeStr.toLowerCase()

  return str === reverseStr(str)
}

function filterNonNumberAndNonChar(s) {
  return s.replace(/[^0-9a-zA-Z]/g, '')
}

function reverseStr(s) {
  return Array.prototype.slice.call(s).reverse().join('')
}
